package com.hl.sfzy.controller;

import com.hl.sfzy.entity.Interest;
import com.hl.sfzy.entity.Problem;
import com.hl.sfzy.service.FmService;
import com.hl.sfzy.service.InterestService;
import com.hl.sfzy.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName InterestController
 * @Description TODO
 * @Author Jerry
 * @Date 2024年01月15日 8:52
 * @Version 1.0
 */
@CrossOrigin
@RestController
@RequestMapping("/interest")
public class InterestController {
    @Autowired
    private InterestService InterestService;
    @PostMapping({"/add"})
    public Result add(@RequestBody Interest Interest) throws Exception {
        this.InterestService.add(Interest);
        return Result.success();
    }

    @PutMapping({"/edit"})
    public Result edit(@RequestBody Interest Interest) {
        this.InterestService.edit(Interest);
        return Result.success();
    }

    @DeleteMapping({"/remove/{id}"})
    public Result remove(@PathVariable Integer id) {
        this.InterestService.remove(id);
        return Result.success();
    }

    @DeleteMapping({"/remove"})
    public Result removeBatch(Integer[] ids) {
        System.out.println(ids);
        this.InterestService.removeBatch(ids);
        return Result.success();
    }


    @GetMapping({"/find"})
    public Result findPage(@RequestParam(value = "pageNum",required = false,defaultValue = "1") Integer pageNum, @RequestParam(value = "pageSize",required = false,defaultValue = "10") Integer pageSize, Interest interest) {
        System.out.println(interest);
        return Result.success(this.InterestService.findPage(pageNum, pageSize, interest));
    }

}
